/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package origendatos.dyd.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author erodrig
 */
@Entity
@Table(name = "CONJUROS")
@NamedQueries({
    @NamedQuery(name = "Conjuros.findAll", query = "SELECT c FROM Conjuros c"),
    @NamedQuery(name = "Conjuros.findByNombre", query = "SELECT c FROM Conjuros c WHERE c.conjurosPK.nombre = :nombre"),
    @NamedQuery(name = "Conjuros.findByNivel", query = "SELECT c FROM Conjuros c WHERE c.conjurosPK.nivel = :nivel"),
    @NamedQuery(name = "Conjuros.findByDescripcion", query = "SELECT c FROM Conjuros c WHERE c.descripcion = :descripcion")})
public class Conjuros implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ConjurosPK conjurosPK;
    @Column(name = "DESCRIPCION", length = 400)
    private String descripcion;
    @JoinTable(name = "CONJUROS_PJ", joinColumns = {
        @JoinColumn(name = "NOMBRE", referencedColumnName = "NOMBRE", nullable = false),
        @JoinColumn(name = "NIVEL_CONJURO", referencedColumnName = "NIVEL", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "PJ_ID", referencedColumnName = "ID", nullable = false)})
    @ManyToMany
    private List<Pj> pjList;

    public Conjuros() {
    }

    public Conjuros(ConjurosPK conjurosPK) {
        this.conjurosPK = conjurosPK;
    }

    public Conjuros(String nombre, int nivel) {
        this.conjurosPK = new ConjurosPK(nombre, nivel);
    }

    public ConjurosPK getConjurosPK() {
        return conjurosPK;
    }

    public void setConjurosPK(ConjurosPK conjurosPK) {
        this.conjurosPK = conjurosPK;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public List<Pj> getPjList() {
        return pjList;
    }

    public void setPjList(List<Pj> pjList) {
        this.pjList = pjList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (conjurosPK != null ? conjurosPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Conjuros)) {
            return false;
        }
        Conjuros other = (Conjuros) object;
        if ((this.conjurosPK == null && other.conjurosPK != null) || (this.conjurosPK != null && !this.conjurosPK.equals(other.conjurosPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "origendatos.dyd.model.Conjuros[conjurosPK=" + conjurosPK + "]";
    }

}
